﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MarketOnlineBUS;
using MarketOnlineDTO;

public partial class cms_ParameterManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadDanhSachThamSo();
            if (Session["key_Search"] != null)
            {
                txtTenThamSo.Text = Session["key_search"].ToString();
                Session["key_search"] = null;
            }
        }
    }

    public void LoadDanhSachThamSo()
    {
        ThamSoBUS tsBUS = new ThamSoBUS();
        List<ThamSoDTO> list = new List<ThamSoDTO>();
        list = tsBUS.LayDanhSachThamSo();
        dtgvDanhSachThamSo.DataSource = list;
        dtgvDanhSachThamSo.DataBind();

        cmbMaThamSo.DataSource = list;
        cmbMaThamSo.DataTextField = "MaThamSo";
        cmbMaThamSo.DataValueField = "MaThamSo";
        cmbMaThamSo.DataBind();
    }
    protected void btnCapNhat_Click(object sender, EventArgs e)
    {
        ThamSoBUS tsBUS = new ThamSoBUS();
        ThamSoDTO tsDTO = new ThamSoDTO();
        tsDTO.MaThamSo = Convert.ToInt32(cmbMaThamSo.SelectedValue);
        tsDTO.TenThamSo = txtTenThamSo.Text;
        tsDTO.GiaTriThamSo = txtGiaTriThamSo.Text;

        tsBUS.CapNhatThamSo(tsDTO);
        LoadDanhSachThamSo();
    }
}